import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:xindong/routes/call/controller/xindong_call_controller.dart';

class XinDongCallActionButton extends StatelessWidget {
  final Function() onPressed;
  final Widget icon;
  final double size;

  const XinDongCallActionButton({Key? key, required this.onPressed, required this.icon, required this.size})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<XinDongCallController>(builder: (controller) {
      return SizedBox(
        width: size,
        height: size,
        child: Stack(
          fit: StackFit.expand,
          children: [
            IconButton(
              onPressed: controller.operationWaiting ? null : onPressed,
              padding: EdgeInsets.zero,
              icon: icon,
            ),
            controller.operationWaiting
                ? const Center(
                    child: SizedBox(
                      width: 20,
                      height: 20,
                      child: CircularProgressIndicator(
                        strokeWidth: 2.5,
                        valueColor: AlwaysStoppedAnimation<Color>(Colors.grey),
                      ),
                    ),
                  )
                : const SizedBox(),
          ],
        ),
      );
    });
  }
}
